ph = input()
br = "([{<"
bri = ")]}>"
stack = []
brm = True
for i in ph:
    if i in br:
        stack.append(i)
    if i in bri:
        if len(stack) == 0 or bri.find(i) != br.find(stack.pop()):
            brm = False
            break
print(len(stack) == 0 and brm)

